/*
* All code licensed under the GPLv2 and CDDL.
* Please visit http://www.gnu.org/licenses/gpl-2.0.html
* and http://www.sun.com/cddl/cddl.html for the full versions of
* these licenses.
 */

/*
 * TwitterappApp.java
 */

package twitterapp;

import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;

/**
 * The main class of the application.
 */
public class TwitterappApp extends SingleFrameApplication {
    /**
     * At startup create and show the main frame of the application.
     */

    @Override protected void startup() {
        show(new TwitterappView(this));
    }

    /**
     * This method is to initialize the specified window by injecting resources.
     * Windows shown in our application come fully initialized from the GUI
     * builder, so this additional configuration is not needed.
     */
    @Override protected void configureWindow(java.awt.Window root) {
    }

    /**
     * A convenient static getter for the application instance.
     * @return the instance of TwitterappApp
     */
    public static TwitterappApp getApplication() {
        return Application.getInstance(TwitterappApp.class);
    }

    /**
     * Main method launching the application.
     */
    public static void main(String[] args) {
        launch(TwitterappApp.class, args);
    }

    public static String connect (String username, String password)
    {
        Connection ConnectionInstance = new Connection();
        String output = ConnectionInstance.Connection(username, password);
        if (output != null)
        {
            javax.swing.JOptionPane.showMessageDialog(null, output);
            ConnectionInstance.HandleData (output,
                                            "account/verify_credentials");
        }
        else
        {
            javax.swing.JOptionPane.showMessageDialog(null,
                    "Could not authenticate.");
        }
        ConnectionInstance = null; //Remove reference to the object so GC can
                                   //remove it.
        return output;
    }
}
